package com.costeaalex.blueserver.interfaces;

import java.awt.Container;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MainFrame extends JFrame
	{
	
	private static final long	serialVersionUID	= 4314548241637458063L;
	private WindowListener wL;
	
	private Container cont;
	private JPanel mainPanel;
	
	public MainFrame()
		{
		super("BlueServer");
		this.setSize(400, 300);
		this.setResizable(false);
		
		wL=new WindowListener();
		this.addWindowListener(wL);
		
		cont=this.getContentPane();
		mainPanel=new JPanel();
		cont.add(mainPanel);
		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		}
	
	public void setMainPanel(JPanel jP)
		{
		cont.removeAll();
		cont.add(jP);
		validate();
		}
	
	public JPanel getMainPanel()
		{
		return (JPanel) cont.getComponent(0);
		}
	
	private class WindowListener extends WindowAdapter
		{
		@Override
		public void windowClosing(WindowEvent winEvt)
			{
			super.windowClosing(winEvt);
			}
		
		@Override
		public void windowIconified(WindowEvent e)
			{
			super.windowIconified(e);
			}
		
		@Override
		public void windowGainedFocus(WindowEvent e)
			{
			super.windowGainedFocus(e);
			}
		
		@Override
		public void windowLostFocus(WindowEvent e)
			{
			super.windowLostFocus(e);
			}
		
		@Override
		public void windowClosed(WindowEvent e)
			{
			super.windowClosed(e);
			}
		
		@Override
		public void windowOpened(WindowEvent e)
			{
			super.windowOpened(e);
			}
		}

	}
